package can.bishe.modules.exam.controller;

import java.util.Arrays;
import java.util.Map;

import can.bishe.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import can.bishe.modules.exam.entity.ExamSubjectOptionEntity;
import can.bishe.modules.exam.service.ExamSubjectOptionService;
import can.bishe.common.utils.PageUtils;
import can.bishe.common.utils.R;



/**
 * 题目选项关系
 *
 * @author can
 * @email 822024417@qq.com
 * @date 2021-04-28 23:03:48
 */
@RestController
@RequestMapping("exam/examsubjectoption")
public class ExamSubjectOptionController {
    @Autowired
    private ExamSubjectOptionService examSubjectOptionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = examSubjectOptionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        ExamSubjectOptionEntity examSubjectOption = examSubjectOptionService.getById(id);

        return R.ok().put("examSubjectOption", examSubjectOption);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ExamSubjectOptionEntity examSubjectOption){
        examSubjectOptionService.save(examSubjectOption);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ExamSubjectOptionEntity examSubjectOption){
        ValidatorUtils.validateEntity(examSubjectOption);
        examSubjectOptionService.updateById(examSubjectOption);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        examSubjectOptionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
